(function (root, factory) {
    'use strict';

    if (typeof define == 'function' && define.amd) {
        define([root, 'jQuery'], factory);
    } else {
        factory(root, jQuery);
    }
})(this, function (root, $) {
    'use strict';
    var Class = (function () {
        var create = (function () {
            var F = function () {

            };

            return function (obj) {
                var subtype;

                F.prototype = obj;

                subtype = new F();

                F.prototype = null;

                return subtype;
            }
        })();

        return {
            create: function () {
                var _deepClone = function (obj) {
                    function isClass(o) {
                        return o === null ? 'Null' : o === undefined ? 'Undefined' : Object.prototype.toString.call(o).slice(8, -1);
                    }

                    var oClass = isClass(obj),
                        result = oClass === 'Object' ? {} : oClass === 'Array' ? [] : obj;

                    for (var key in obj) {
                        var copy = obj[key];
                        result[key] = isClass(copy) === 'Object' || isClass(copy) === 'Array' ? _deepClone(copy) : copy;
                    }
                    return result;
                };

                return function () {
                    var instance = create(_deepClone(this));
                    instance.initialize.apply(instance, arguments);
                    return instance;
                }
            }
        }
    })()
    root.Class = Class;
})

